package com.itheima.dubbo.mysql.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itheima.commons.pojo.domain.HuanxinUser;
import com.itheima.dubbo.interfaces.HuanxinUserApi;
import com.itheima.dubbo.mysql.mapper.HuanxinUserMapper;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author yaohu
 * @date 2021/12/11
 * @Version 1.0
 * @describe
 */
@Service
public class HuanxinUserApiImpl implements HuanxinUserApi {

    @Autowired
    private HuanxinUserMapper huanxinUserMapper;

    /**
     * 新建环信用户
     *
     * @param huanxinUser
     */
    @Override
    public void addUser(HuanxinUser huanxinUser) {
        huanxinUserMapper.insert(huanxinUser);
    }

    /**
     * 根据userId 查询环信用户信息
     *
     * @param userId
     * @return
     */
    @Override
    public HuanxinUser findHXUserByUserId(Long userId) {
        return huanxinUserMapper.selectOne(Wrappers.lambdaQuery(HuanxinUser.class)
                        .eq(HuanxinUser::getUserId, userId));
    }
}
